const Koa = require('koa')
const bodyParser = require('koa-bodyparser')
const app = new Koa()
const routing = require('./routes')


app.use(async (ctx, next) => {
    try {
        await next()
    } catch (err) {
        // 捕捉不到404错误
        ctx.status = err.status || err.statusCode || 500
        ctx.body = {
            message: err.message
        }
    }
})
app.use(bodyParser())

routing(app)

app.listen(3000, () => {
    console.log('程序启动在3000端口啦')
})